//引入所需模块
var express = require('express');
var ejs = require('ejs');
var path = require('path');
var router = require('./router/index.js');
var ajaxMidWare = require('./ajax/ajax');
var app = express();
/** 设置模板引擎为 ejs 并设置后辍名为html */
app.engine('html', ejs.renderFile);
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'template'));  
//识别ejs模板引擎代码
app.set('view engine','ejs');

//站点静态资源目录(图片、样式、js、字体.....)
app.use('/public', express.static(path.join(__dirname, 'assets'))); // 
//整站路由
app.use(router);
//定义ajax指向
app.use('/ajax',ajaxMidWare)

module.exports = app;
/*app.listen(3000,function(){
   console.log('server is running at port: 3000')
});*/